from urllib import request

# url = 'https://www.allhistory.com/map'
url = 'https://www.6baike.com/wiki/HuNanLiShi/index.html'
headers = {
    'cookie': 'Hm_lvt_efa3bcadaf3a1f1185241054bd06d14b=1616070361; oaplmlastsearchtime=1616071177; Hm_lpvt_efa3bcadaf3a1f1185241054bd06d14b=1616071579',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36 Edg/89.0.774.50'
}
req = request.Request(url, headers=headers)
res = request.urlopen(req)
print(res.info())
print(res.getcode())
print(res.geturl)
html = res.read()
html = html.decode('utf-8')
print(html)

# request的基本使用
